package com.cos.lession72.slice;

import com.cos.lession72.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Image;
import ohos.agp.components.Picker;
import ohos.agp.utils.Color;
import ohos.agp.window.dialog.ToastDialog;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class PickerAbilitySlice extends AbilitySlice {
    int count=0;
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_picker);
        //获取选择器对象
        Picker pic = (Picker) findComponentById(ResourceTable.Id_myPicker);
        //设置最小最大值
        pic.setMinValue(0);
        pic.setMaxValue(6);
        pic.setShaderColor(new Color(Color.getIntColor("#1E90FF")));
        pic.setDisplayedData(new String[]{"星期一","星期二","星期三","星期四","星期五","星期六","星期天"});
        //获取选中的值
        pic.setValueChangedListener(new Picker.ValueChangedListener() {
            @Override
            public void onValueChanged(Picker picker, int i, int i1) {
                // i老的选中值  i1新的选中值
                new ToastDialog(getContext())
                        .setText(i+"====>"+i1)
                        .setDuration(5000)
                        .show();
            }
        });
    }
}
